﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using Los.Core;
using FerryDev.Excel;

namespace StudentImporter
{
    public partial class Form1 : Form
    {
        IEnumerable<Relation> rels;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FileInfo f = new FileInfo(Application.ExecutablePath);
            rels = Importer.FromXls(f.Directory + "\\murid2010.xls");

            progressBar1.Maximum = rels.Count();

            int i = 0;
            foreach (Relation r in rels)
            {
                listBox1.Items.Add(r);
                r.Insert();
                progressBar1.Value = i++;
                Application.DoEvents();
            }

            MessageBox.Show("Finished importing");
        }
    }
}
